package ca.nfb.media.nfbPlayer.views
{
	import flash.events.Event;
	
	public class NotFoundErrorView extends NFBPlayerView
	{
		public function NotFoundErrorView()
		{
			super();
			this.visible = false;
			core.screenReaderManager.addAccess(this, "File not found", "Fichier introuvable.");
		}
		
		override protected function coreStateUpdated(evt:Event=null):void
		{
			if (core.currentState == NFBPlayer.FILE_NOT_FOUND_STATE)
			{
				show();
			}
			else
			{
				this.visible = false;
			}
		}
		
		public function show():void
		{
			var localWidth:Number = stage.stageWidth;
			var localHeight:Number = stage.stageHeight;
			
		
			this.scaleX = 1;
			
			if (this.width > localWidth)
			{
				this.width = localWidth-6;
			}
			else
			{
				localWidth = this.width;
			}
			this.scaleY = this.scaleX;
			
			if (this.height > localHeight)
			{
				this.height = localHeight-6;
				this.scaleX = this.scaleY;
			}
			
			this.x = (stage.stageWidth - this.width) / 2;
			this.y = ((localHeight-core.controllerHeight) - this.height) / 2;
			this.visible = true;
		}
		
		override protected function stageResized(evt:Event=null):void
		{
			var localWidth:Number = stage.stageWidth >= core.minimumWidth ? stage.stageWidth : core.minimumWidth;
			var localHeight:Number = stage.stageHeight >= core.minimumHeight ? stage.stageHeight : core.minimumHeight;
			
			this.scaleX = 1;
			
			if (this.width > localWidth)
			{
				this.width = localWidth-6;
			}
			else
			{
				localWidth = this.width;
			}
			this.scaleY = this.scaleX;
				
			
			if (this.height > localHeight)
			{
				this.height = localHeight-6;
				this.scaleX = this.scaleY;
			}
			
			this.x = (stage.stageWidth - this.width) / 2;
			this.y = ((localHeight-core.controllerHeight) - this.height) / 2;
		}
		
	}
}